﻿param($exportFilePath)

$parentPath=(Split-Path $PSCommandPath -Parent)

Import-Module -Force $parentPath\..\BuildDeployment\libAssertion.psm1

Assert-Directory -Path $exportFilePath

Write-Host $exportFilePath

$hbaCount=3

while($true)
{
    for($i=1;$i -le $hbaCount;$i++)
    {
        Write-Host -NoNewline "Capturing temperature sample for HBA $i on $env:COMPUTERNAME..."
        $hbaTemp=&$parentPath\scrtnycli_x64.exe -i $i show -temp
        $hbaTemperatureStatistics=New-Object PSObject -Property @{  ComputerName=$env:COMPUTERNAME;
                                                                    SampleTime=(Get-Date -Format G);
                                                                    HBAIndex=$i;
                                                                    IOCTemperature=$hbaTemp[5].Replace("IOC Temperature      : ","").Replace(" C","").Replace(" ","");
                                                                    }
        Write-Host "Temperature for HBA is" $hbaTemperatureStatistics.IOCTemperature "C"                                                             
        $hbaTemperatureStatistics | Export-Csv -Path $exportFilePath`HBATemperatureStatistics.csv -Append -NoTypeInformation
    
    }
    Write-Host "Waiting before next sample, now is the time to interrupt."
    Start-Sleep -Seconds 30
}
